<template>
	<view class="">
		<navView navTitle="知识产权" titleColor="#fff" :isBack="true"></navView>
		<view class="container">
			<!-- <view class="quan">
				全选
			</view> -->
			<!-- 列表内容 -->
			<view class="content">
				<view class="item" v-for="(item, index) in items" :key="index"
					@tap="$navTo('/pages/knowledge/sendpay?id=' + item.property_id + '&amount=' + item.payment_info.unpaid)">
					<view class="checkbox-container">
						<!-- <checkbox-group @change="checkboxChange">
							<label class="checkbox-label">
								<checkbox :checked="item.selected" :value="item.name" class="checkbox" />
							</label>
						</checkbox-group> -->
						<text class="item-name">{{ item.contract_name }}</text>
					</view>
					<view class="details">
						<text class="label">合同编号：</text>
						<text class="value">{{ item.contract_num }}</text>
					</view>
					<view class="details">
						<text class="label">合同名称：</text>
						<text class="value">{{ item.contract_name }}</text>
					</view>
					<view class="details">
						<text class="label">专利名称：</text>
						<text class="value">{{ item.property_name }}</text>
					</view>
					<view class="details">
						<text class="label">专利编号：</text>
						<text class="value">{{ item.property_number }}</text>
					</view>
					<view class="details">
						<text class="label">专利类型：</text>
						<text class="value">{{ item.property_type }}</text>
					</view>
					<view class="details">
						<text class="label">缴费金额：</text>
						<text class="value">{{ item.payment_count }}</text>
					</view>
				</view>
			</view>

			<!-- 底部合计和按钮 -->
			<!-- <view class="footer">
				<view class="total">
					合计 （元）：
					<text class="total-amount">{{ totalAmount }}</text>
				</view>
				<button class="generate-btn" @click="generatePayCode">支付二维码</button>
			</view> -->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 列表数据
				items: [{
						name: '此处是名称',
						type: '专利权',
						object: '对象名称对象名称对象名称对象名称对象名称对象名称',
						fee: '1000',
						selected: false,
					},
					{
						name: '此处是名称',
						type: '专利权',
						object: '对象名称对象名称对象名称对象名称对象名称对象名称',
						fee: '1000',
						selected: false,
					},
				],
				// 合计金额
				totalAmount: 0,
				list:[]
			};
		},
		onLoad() {
			this.getList()
		},
		methods: {
			// 返回上一页
			goBack() {
				uni.navigateBack();
			},
			// 复选框状态改变
			checkboxChange(e) {
				const selectedItems = this.items.filter((item) => item.selected);
				this.totalAmount = selectedItems.reduce((sum, item) => sum + Number(item.fee), 0);
			},
			// 生成支付二维码
			generatePayCode() {
				console.log('生成支付二维码');
				// 这里可以调用支付接口生成二维码
			},
			getList(){
				this.$request('/addons/qingdong/contract/getUserPropertyList', 'GET').then(res=>{
					this.items = res.data.patents
				})
			}
		},
		created() {
			// 初始化合计金额
			this.totalAmount = this.items
				.filter((item) => item.selected)
				.reduce((sum, item) => sum + Number(item.fee), 0);
		},
	};
</script>

<style lang="scss">
	.container {
		padding: 20rpx;
		box-sizing: border-box;

		.quan {
			font-weight: 400;
			font-size: 24rpx;
			color: #FFFFFF;
			margin-bottom: 20rpx;
		}

		.item {
			margin-bottom: 24rpx;
			padding: 24rpx;
			border-radius: 16rpx;
			background-color: #ffffff;
			box-shadow: 0 4rpx 8rpx rgba(0, 0, 0, 0.1);
		}

		.checkbox-container {
			display: flex;
			align-items: center;
			margin-bottom: 16rpx;
			border-bottom: 1rpx dashed #ccc;
			padding-bottom: 20rpx;
		}

		.checkbox-label {
			display: flex;
			align-items: center;
			margin-right: 16rpx;
		}

		.checkbox {
			width: 48rpx;
			height: 48rpx;
			margin-right: 16rpx;
			border: 1rpx solid #d5d5d5;
			border-radius: 8rpx;
		}

		.item-name {
			font-size: 24rpx;
			font-weight: bold;
		}

		.details {
			display: flex;
			align-items: center;
			margin-top: 8rpx;
			font-size: 24rpx;
		}

		.label {
			color: #888888;
			width: 120rpx;
		}

		.value {
			width: calc(100% - 150rpx);
			color: #333333;
			padding-left: 20rpx;
			box-sizing: border-box;
			margin-left: 16rpx;
		}

		.footer {
			width: 100%;
			position: fixed;
			bottom: 0;
			left: 0;
			box-sizing: border-box;
			border-top: 1rpx solid #ccc;
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 24rpx;
			background-color: #ffffff;
		}


		.total {
			font-size: 30rpx;
		}

		.total-amount {
			color: #ff4500;
			font-size: 36rpx;
			font-weight: bold;
		}

		.generate-btn {
			height: 80rpx;
			border-radius: 20rpx;
			background-color: #2979ff;
			color: #ffffff;
			font-size: 30rpx;
			margin: 0;
			text-align: center;
			line-height: 80rpx;
		}
	}
</style>